<?php
declare(strict_types=1);
/**
 * MineAdmin is committed to providing solutions for quickly building web applications
 * Please view the LICENSE file that was distributed with this source code,
 * For the full copyright and license information.
 * Thank you very much for using MineAdmin.
 *
 * @Author X.Mo<root@imoi.cn>
 * @Link   https://gitee.com/xmo/MineAdmin
 */
namespace Plugin\Organization\Http\Request\Admin;

use Hyperf\Validation\Request\FormRequest;

/**
 * 项目线表验证数据类
 */
class RdOrganizeProjLineRequest extends FormRequest
{
    /**
     * 场景配置
     */
    protected array $scenes = [
        'index' => [
            'name',
            'zone_id',
            'line_arr',
            'line_style',
            'status',
            'sort',
            'created_by',
            'updated_by',
            'created_at',
            'updated_at',
            'deleted_at',
        ],
        'create' => [
            'name',
            'zone_id',
            'line_arr',
            'line_style',
            'status',
            'sort',
            'remark'
        ],
        'update' => [
            'name',
            'zone_id',
            'line_arr',
            'line_style',
            'status',
            'sort',
            'remark'
        ]
    ];

    public function authorize(): bool
    {
        return true;
    }


    /**
     * 新增数据验证规则
     * return array
     */
    public function rules(): array
    {
        return [
            'name' => 'string|max:50',
            'zone_id' => 'integer|min:1|exists:rd_organize_zone,id',
            'line_arr' => 'array',
            'line_style' => 'array',
            'status' => 'in:1,2',
            'sort' => 'integer|min:0',
            'remark' => 'nullable|string|max:255',
            'created_by' => 'integer|min:1',
            'updated_by' => 'integer|min:1',
        ];
    }


    /**
     * 字段映射名称
     * return array
     */
    public function attributes(): array
    {
        return [
            'id' => '主键',
            'name' => '项目线名称',
            'zone_id' => '所属区域',
            'line_arr' => '项目线点数组',
            'line_style' => '线条样式',
            'status' => '状态',
            'sort' => '排序',
            'created_by' => '创建者',
            'updated_by' => '更新者',
            'remark' => '备注',

        ];
    }

public function messages(): array
{
    return [
            'id.required' => '必填主键',
            'name.required' => '必填项目线名称',
            'zone_id.required' => '必填所属区域',
            'line_arr.required' => '必填项目线点数组',
            'line_style.required' => '必填线条样式',
            'status.required' => '必填状态',
            'sort.required' => '必填排序',
            'created_by.required' => '必填创建者',
            'updated_by.required' => '必填更新者',
            'remark.required' => '必填备注',

    ];
}
}